package com.credithc.customers.base.ro;

import com.credithc.customers.base.codes.CustomerCodes;
import com.credithc.customers.base.exception.CustomerException;
import com.credithc.customers.base.utils.CustomerUtils;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

/**
 * @description: 统一登录忘记/修改密码
 * @author: fby
 * @date: 2019/7/8 15:47
 * @param: null
 * @return:
 */
@Data
public class UnifySmsPwdRo extends CustomerBaseRo {

    private String phone;

    private String ip;

    private String smsType;


    public static void checkBaseParam(UnifySmsPwdRo ro) {
//        if (StringUtils.isBlank(ro.getPhone())) {
//            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "手机号/登录凭证不能为空");
//        }
        CustomerUtils.checkPhone(ro.getPhone());
        if (StringUtils.isBlank(ro.getRequestNo())) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "请求流水号不能为空");
        }
        if (StringUtils.isBlank(ro.getSmsType())) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "短信模板类型不能为空");
        }
        if (!"1".equals(ro.getSmsType())) {
            throw new CustomerException(CustomerCodes.PARAM_VALIDATE_ERROR, "未配置该短信模板类型，请联系管理员");
        }
    }
}
